from StartGroup.models import Group
from django import forms
from django.conf import settings
from django import forms
import datetime
from discussions.models import Discussion
from discussions.models import Disc_Comment

attrs_dict = { 'class': 'required' }

class StartNewDiscussionForm(forms.Form):
    
    topic = forms.CharField(max_length=200, required=True, label='DISCUSSION TOPIC', error_messages={'required': 'Please enter Discussion Topic'},
                                widget=forms.TextInput(attrs={'size':'50'}))
    topic_desc = forms.CharField(max_length=500, label='TOPIC DESCRIPTION', error_messages={'required': 'Please enter Topic Description'},
                                widget=forms.Textarea(attrs={'size':'200', 'cols':'100', 'rows':'5'}))
    post_date = datetime.date.today()
    last_update_dt = datetime.date.today()
    
    def save(self, group_info, memberName, memberImgPath):
        new_discussion = Discussion(group = group_info,
                                topic=self.cleaned_data['topic'],
                                topic_desc=self.cleaned_data['topic_desc'],
                                post_by = memberName,
                                last_post_by = memberName,
                                photo = memberImgPath
                                )
        new_discussion.save()
        return new_discussion


class PostNewCommentForm(forms.Form):
    
    comment = forms.CharField(max_length=200, required=True, label='COMMENT', error_messages={'required': 'Please enter a place for event'},
                                widget=forms.Textarea(attrs={'size':'200', 'cols':'100', 'rows':'2','id':'commentBoxId'}))

    post_date = datetime.date.today()

    def save(self, disc_info, memberName, memberImgPath):
        comment_update = Disc_Comment(discussion = disc_info,
                                comment=self.cleaned_data['comment'],
                                post_by = memberName,
                                photo = memberImgPath
                                )
        comment_update.save()
        return comment_update